package com.woniuxy.util;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @BelongsProject: pigTrotterStore
 * @BelongsPackage: com.woniuxy.util
 * @Author: Quan
 * @Date: 2025/3/8 11:56
 */
@Data
@AllArgsConstructor
public class ResponseData<T> {
	private Integer code;
	private T data;
	private String msg;

	public static <T> ResponseData<T> ok() {
		return new ResponseData<>(
				ResponseEnum.SUCCESS.getCODE(),
				null,
				ResponseEnum.SUCCESS.getMSG());
	}

	public static <T> ResponseData<T> ok(T data) {
		return new ResponseData<>(
				ResponseEnum.SUCCESS.getCODE(),
				data,
				ResponseEnum.SUCCESS.getMSG()
		);
	}

	public static <T> ResponseData<T> fail(ResponseEnum responseEnum) {
		return new ResponseData<>(
				responseEnum.getCODE(),
				null,
				responseEnum.getMSG()
		);
	}

	public static <T> ResponseData<T> fail(ResponseEnum responseEnum, T data) {
		return new ResponseData<>(
				responseEnum.getCODE(),
				data,
				responseEnum.getMSG()
		);
	}
}
